<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>BOM : history</title>

    <script type="text/javascript">
    
        console.log( 'history.length : ' , history.length );

        let x = {
            back: function(){
                console.log( '返回上一个页面' );
                history.back();
            },
            forward: function(){
                console.log( '进入上一个页面' );
                history.forward();
            },
            go: function( position ){
                history.go( position )
            }
        }

    </script>

</head>
<body>

    <button type="button" onclick="x.go(-2)">-2</button>
    <button type="button" onclick="x.go(-1)">-1</button>
    <button type="button" onclick="x.back()">后退(back)</button>
    <button type="button" onclick="x.forward()">前进(forward)</button>
    <button type="button" onclick="x.go(1)">1</button>
    <button type="button" onclick="x.go(2)">2</button>
    
</body>
</html>